﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Domain.EquipmentProcessDomain;

namespace Zocono.WCS.Domain.ProcessModuleDomain
{
    public class ProcessModuleScService : IProcessMuduleService
    {
        private readonly IProcessScService _processScService;
        private readonly ILogUtil _logUtil;

        public ProcessModuleScService(IProcessScService processScService, ILogUtil logUtil)
        {
            _processScService = processScService;
            _logUtil = logUtil;
        }

        public async Task ProcessDbObjectAsync(ProcessModule processModule/*, ProcessModule plcStateProcessModule*/)
        {
            var scEquipmentDbObject = processModule.equipmentDbObjects.Find(e => e.EquipmentCode.ToString().Contains("SC"));//PlcConnectionInfo中SC
            var puDoEquipmentDbObjects = processModule.equipmentDbObjects.FindAll(e => !e.EquipmentCode.ToString().Contains("SC"));
            if (scEquipmentDbObject != null /*&& puDoEquipmentDbObjects.Count > 0*/)
                await _processScService.ProcessAsync(processModule.ProcessModuleName, scEquipmentDbObject, puDoEquipmentDbObjects);
            else
                _logUtil.Info("空值报警！！！请检查scEquipmentDbObject和puDoEquipmentDbObjects报文是否为空");
        }

    }
}
